home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / AmigaTalk / Intuition / Painter.st < prev    next >
Text File  |  2000-05-08  |  4KB  |  171 lines

  1. "----------------------------------------------------"
  2. " Painter Class implements simple graphics primitives"
  3. "----------------------------------------------------"
  4.  
  5. Class Painter :Glyph
  6. ! frontPen backPen otherPen drawMode x y ownerWindow !
  7. [
  8.    setAPen: pen
  9.       <primitive 200 0 ownerWindow pen>.
  10.       frontPen <- pen
  11. |
  12.    setBPen: pen
  13.       <primitive 200 1 ownerWindow pen>.
  14.       backPen <- pen
  15. |
  16.    setOPen: pen
  17.       <primitive 200 2 ownerWindow pen>.
  18.       otherPen <- pen
  19. |
  20.    setDrawMode: mode
  21.       <primitive 200 3 ownerWindow mode>.
  22.       drawMode <- mode
  23. |
  24.    getPens
  25.       ^ frontPen @ backPen
  26. |
  27.    getOPen
  28.       ^ otherPen
  29. |
  30.    getDrawMode
  31.       ^ drawMode
  32. |
  33.    location
  34.       ^ x @ y
  35. |
  36.    ownerIs
  37.       ^ ownerWindow
  38. |
  39.    movePenTo: newPoint
  40.       x <- newPoint x.
  41.       y <- newPoint y.
  42.       <primitive 200 4 ownerWindow x y>
  43. |
  44.    drawTo: aPoint
  45.       x <- aPoint x.
  46.       y <- aPoint y.
  47.       <primitive 200 5 ownerWindow x y>
  48. |
  49.    drawLineFrom: fPoint to: tPoint
  50.       x <- tPoint x.
  51.       y <- tPoint y.
  52.       <primitive 200 6 ownerWindow (fPoint x) (fPoint y) x y>
  53. |
  54.    drawBoxFrom: fPoint to: tPoint
  55.       <primitive 200 7 ownerWindow (fPoint x) (fPoint y) (tPoint x) (tPoint y)>
  56. |
  57.    drawCircle: cPoint radius: r
  58.       <primitive 200 9 ownerWindow (cPoint x) (cPoint y) r r>
  59. |
  60.    drawEllipse: cPoint minaxis: a maxaxis: b
  61.       <primitive 200 9 ownerWindow (cPoint x) (cPoint y) a b>
  62. |
  63.    drawPolygon: borderName
  64.       <primitive 200 10 ownerWindow borderName>
  65. |
  66.    drawPixelAt: aPoint
  67.       x <- aPoint x.
  68.       y <- aPoint y.
  69.       <primitive 200 11 ownerWindow x y>
  70. |
  71.    drawText: text at: aPoint
  72.       <primitive 200 19 ownerWindow text (aPoint x ) (aPoint y)>
  73. |
  74.    new: newOwnerWindow
  75.       ownerWindow <- newOwnerWindow.
  76.       frontPen    <- 1.
  77.       backPen     <- 0.
  78.       otherPen    <- 2.
  79.       drawMode    <- 0.  "JAM1 == 0"
  80.       x           <- 0.
  81.       y           <- 0.
  82.       ^ self
  83. ]
  84.  
  85. "----------------------------------------------------"
  86. " Image Class implements Image graphics primitives   "
  87. "----------------------------------------------------"
  88.  
  89. Class Image :Glyph
  90. ! leftEdge  topEdge    width     height      depth 
  91.   planePick planeOnOff nextImage ownerWindow imageName
  92. !
  93. [
  94.    ownerIs
  95.       ^ ownerWindow
  96. |
  97.    getStartPoint
  98.       leftEdge <- <primitive 200 14 ownerWindow 0 imageName>.
  99.       topEdge  <- <primitive 200 14 ownerWindow 1 imageName>.
  100.       ^ leftEdge @ topEdge
  101. |
  102.    getImageSize
  103.       width  <- <primitive 200 14 ownerWindow 2 imageName>.
  104.       height <- <primitive 200 14 ownerWindow 3 imageName>.
  105.       ^ width @ height
  106. |
  107.    setOrigin: aPoint ! x y !
  108.       x <- aPoint x.
  109.       y <- aPoint y.
  110.       <primitive 200 15 ownerWindow 0 x imageName>.
  111.       <primitive 200 15 ownerWindow 1 y imageName>.
  112.       leftEdge <- x.
  113.       topEdge  <- y
  114. |
  115.    setExtent: sizePoint ! w h !
  116.       w <- sizePoint x.
  117.       h <- sizePoint y.
  118.       <primitive 200 15 ownerWindow 2 w imageName>.
  119.       <primitive 200 15 ownerWindow 3 h imageName>.
  120.       width  <- w.
  121.       height <- h
  122. |
  123.    setImageDepth: d
  124.       <primitive 200 15 ownerWindow 4 d imageName>.
  125.       depth <- d
  126. |
  127.    addImage: w height: h depth: d
  128.       <primitive 200 13 ownerWindow w h d imageName>
  129. |
  130.    drawImageAt: aPoint
  131.       <primitive 200 16 ownerWindow (aPoint x) (aPoint y) imageName>
  132. |
  133.    setImageDataFrom: imageFile
  134.       <primitive 200 17 ownerWindow imageFile imageName>
  135. |
  136.    getImageDepth
  137.       ^ depth <- <primitive 200 14 ownerWindow 4 imageName>
  138. |
  139.    getImagePlanePick
  140.       ^ planePick <- <primitive 200 14 ownerWindow 6 imageName>
  141. |
  142.    getImagePlaneOnOff
  143.       ^ planeOnOff <- <primitive 200 14 ownerWindow 7 imageName>
  144. |
  145.    getNextImage
  146.       ^ nextImage <- <primitive 200 14 ownerWindow 8 imageName>
  147. |
  148.    setImagePlanePick: pp
  149.       <primitive 200 15 ownerWindow 6 pp imageName>.
  150.       planePick <- pp
  151. |
  152.    setImagePlaneOnOff: po
  153.       <primitive 200 15 ownerWindow 7 po imageName>.
  154.       planeOnOff <- po
  155. |
  156.    setNextImage: newNextImage
  157.       <primitive 200 15 ownerWindow 8 newNextImage imageName>.
  158.       nextImage <- newNextImage
  159. |
  160.    new: newImageName
  161.       imageName <- newImageName.
  162.       ^ self
  163. |
  164.    registerTo: newWindowName
  165.       ownerWindow <- newWindowName.   
  166.       <primitive 200 18 ownerWindow imageName>
  167. |
  168.    removeImage
  169.       <primitive 200 12 ownerWindow imageName>
  170. ]
  171.